GtkMenuSectionBox: don't leak
authorMatthias Clasen <mclasen@redhat.com>
Tue, 29 Apr 2014 14:18:22 +0000 (10:18 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Tue, 29 Apr 2014 14:18:22 +0000 (10:18 -0400)
This wasn't fully fleshed out yet.

gtk/gtkmenusectionbox.c

index 76640f9cbf49096ae8f8fcff0b2308e0671b10ec..8891f59d87f14e626eddf47d1cf1d0a09065a9ef 100644 (file)
@@ -293,6 +293,24 @@ gtk_menu_section_box_dispose (GObject *object)
       box->separator_sync_idle = 0;
     }
 
+  if (box->separator)
+    {
+      gtk_widget_destroy (box->separator);
+      box->separator = NULL;
+    }
+
+  if (box->size_group)
+    {
+      g_object_unref (box->size_group);
+      box->size_group = NULL;
+    }
+
+  if (box->tracker)
+    {
+      gtk_menu_tracker_free (box->tracker);
+      box->tracker = NULL;
+    }
+
   G_OBJECT_CLASS (gtk_menu_section_box_parent_class)->dispose (object);
 }
 
@@ -416,6 +434,8 @@ gtk_menu_section_box_new_section (GtkMenuTrackerItem *item,
       gtk_widget_show (box->separator);
     }
 
+  g_object_add_weak_pointer (G_OBJECT (box->separator), (gpointer *)&(box->separator));
+
   box->tracker = gtk_menu_tracker_new_for_item_link (item, G_MENU_LINK_SECTION, FALSE,
                                                      gtk_menu_section_box_insert_func,
                                                      gtk_menu_section_box_remove_func,